<template>
	<view class="content">
		<view class="title" style="margin-top: 200rpx;">您的体重是？</view>

		<view>
			<picker-view v-if="visible" :indicator-style="indicatorStyle" :value="value" @change="bindChange"
				class="picker-view" mask-style="background:transparent;">
				<picker-view-column>
					<view class="item" :class="{ select: item == year }" v-for="(item, index) in years" :key="index">
						{{ item.value }}
					</view>
				</picker-view-column>
			</picker-view>
		</view>

		<view class="bottom" style="margin-top: 260rpx;">
			<view @click="back">
				<u-icon name="arrow-leftward" color="#222" size="50"></u-icon>
			</view>
			<view class="btn" @click="next">
				<view class="bin-confirm">OK了</view>
				<u-icon name="arrow-rightward" color="#fff" size="28"></u-icon>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const years = [];
			return {
				// $c: this.$common,
				// current: 0,
				// swiperHeight: 0,
				data: {
					device: '478ca4671a993355',
					sex: '1',
					nickname: '',
					birthday: '',
					height: '',
					weight: '',
					career: '',
					income: '',
					save_city: '',
					avatar: '',
					phone: '',
					code: '',
					password: '',
				},
				title: 'picker-view',
				years,
				year: '',
				value: [0],
				visible: true,
				indicatorStyle: `height: 50px;`,
				tizhongid: 1
			};
		},
		onLoad() {
			this.getData();
			this.data = uni.getStorageSync('registerInfo');
		},
		methods: {
			back(){
				uni.navigateBack();
			},
			async getData() {
				let res = await this.$common.post('/app/user/getTizhong');
				this.years = res.data;
			},

			bindChange: function(e) {
				const val = e.detail.value;
				this.data.weight = this.years[val[0]].value;
				this.tizhongid = this.years[val[0]].id;
				this.year = this.years[val[0]];
			},

			async next() {

				let res = await this.$common.post('/app/geren/uptizhong?tizhong=' + this.tizhongid);
				uni.setStorageSync('registerInfo', this.data);
				uni.navigateTo({
					url: "/pages/register/register5"
				})
			}
		}
	};
</script>

<style lang="scss">
	.content {
		width: 100wh;
		height: 100vh;
		margin: 0 50rpx;

		.title {
			font-weight: bold;
			font-size: 48rpx;
			color: #222;
		}

		.bottom {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
		
			.btn {
				display: flex;
				flex-direction: row;
				justify-content: center;
				align-items: center;
				width: 150rpx;
				height: 80rpx;
				background-color: #222;
				border-radius: 10rpx;
		
				.bin-confirm {
					color: white;
					font-size: 24rpx;
				}
			}
		}

		.picker-view {
			width: 100%;
			height: 600rpx;
			margin: 0 auto;
		}

		.item.select {
			color: #000;
			font-size: 36rpx;
			font-weight: 600;
		}

		.item {
			height: 50px;
			line-height: 50px;
			text-align: center;
			color: #999999;
		}

	}
</style>